

/*

Dofile: figure1.do 

Date: Dec. 10, 2016 
Aim: Non-linear effect of the tax rate   

Input: base_for_reg.dta 
Output: figure1.eps 
Reported in the paper: "Figure 1 – Corporate tax rate on transfer pricing across tax deciles"

*/  

cd $datapath
use base_for_reg, clear 

drop cty_*
qui tab pays, g(cty_) 

global control inter_linvemtr inter_ldist inter_tarif inter_lgdpc cty_*
xtreg luv type  $control $condition, fe i(fpt) cluster(pays) nonest
keep if e(sample) 
egen test=group(iso3) 
sum test

preserve 
egen group=group(iso3 emtr)
duplicates drop  group , force 
xtile q_emtr=emtr, n(10) 
bys q_emtr: tab iso3 
keep iso3 q_emtr
sort iso3 
save q_emtr, replace 

restore
sort iso3 
merge m:1 iso3 using q_emtr 
drop _m 

qui tab q_emtr, g(q_)

forvalue i = 1(1)10{
g inter_`i'=type*q_`i'
}

egen memtr=mean(emtr) , by(q_emtr)

save tempi, replace 

cd $dopath
global condition 
global lab 1
do figure 
